<?php

class SignupForm extends sfForm
{
  public function configure()
  {
    $this->setWidgets(array(
      'email' => new sfWidgetFormInput(),
      'password' => new sfWidgetFormInputPassword(),
      'repassword' => new sfWidgetFormInputPassword()
    ));

    $this->widgetSchema->setLabels(array(
      'email'  => 'E-Mail',
      'password'  => 'Password',
      'repassword'  => 'Re-Password',
    ));

	//$this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'repassword'));




    $this->setValidators(array(
      'email'      =>  new sfValidatorAnd(
			            array(
			                new sfValidatorDoctrineUnique(	array('model' => 'User', 'column' => 'email', 'primary_key' => 'id', 'required' => true, 'throw_global_error' => true ),
			                								array('invalid' =>	'↓ El correo electrónico ya existe en nuestra base de datos. ↓')),
			                new sfValidatorEmail(array('required' => true), array('required' => '↓ Es necesario indicar el correo electrónico. ↓', 'invalid' => '↓ Es necesario indicar un correo electrónico válido. ↓')),
			            )
			        ),
      'password'   => new sfValidatorString(array('required' => true), array('required' => '↓ Es necesario indicar el password. ↓')),
      'repassword' => new sfValidatorString(array('required' => true), array('required' => '↓ Es necesario indicar el password. ↓'))
    ));

	$this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'repassword', array(), array('invalid' => '↓ Las contraseñas no coinciden. ↓')));
  }
}
